---
id: app
title: 1. App 静态类
sidebar_label: 1. App 静态类
---

## 1.1 获取全局配置

```cs
var settings = App.Settings;
```

## 1.2 获取配置对象

```cs
var configuration = App.Configuration;

var data = App.GetConfig<TConfig>("key:key2");
```

## 1.3 获取环境对象

```cs
var webHostEnvironment = App.WebHostEnvironment;
```

## 1.4 获取项目所有程序集

```cs
var assemblies = App.Assemblies;
```

## 1.5 获取项目所有有效类型

```cs
var types = App.EffectiveTypes;
```

## 1.6 获取 `HttpContext`

```cs
var httpContext = App.HttpContext;
```

## 1.7 获取登录的 `User` 对象

```cs
var contextUser = App.User;
```

## 1.8 获取服务提供器

```cs
var serviceProvider = App.ServiceProvider;
```

## 1.9 解析服务

```cs
var service = App.GetService<TService>();
var service2 = App.GetService(typeof(TService));

var service3 = App.GetRequiredService<TService>();
var service4 = App.GetRequiredService(typeof(TService));
```

## 1.10 获取选项配置

```cs
var options = App.GetOptions<TOptions>();
var options2 = App.GetOptionsMonitor<TOptions>();
var options3 = App.GetOptionsSnapshot<TOptions>();
```

## 1.11 打印数据到 `MiniProfiler`

```cs
App.PrintToMiniProfiler("分类", "状态", "要打印的消息");
```